// HotelMgr.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "App.h"
#include "DataEngine.h"
#include "Login.h"


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	//LoadConfig();
	/*FILE* fp=fopen("conf.do","wb");
	int ver=0;
	char* pHost="HotelMgr";
	char* pUsername="root";
	char* pPassword="123456";
	int hostlen=strlen(pHost);
	int userlen=strlen(pUsername);
	int pwdlen=strlen(pPassword);
	int port=3306;
	fwrite(&ver,sizeof(int),1,fp);
	fwrite(&hostlen,sizeof(int),1,fp);
	fwrite(pHost,hostlen,1,fp);
	fwrite(&userlen,sizeof(int),1,fp);
	fwrite(pUsername,userlen,1,fp);
	fwrite(&pwdlen,sizeof(int),1,fp);
	fwrite(pPassword,pwdlen,1,fp);
	fwrite(&port,sizeof(port),1,fp);
	fclose(fp);*/
	HANDLE hMutex = CreateMutex(NULL, FALSE, "HotelMgr");
	if (GetLastError() == ERROR_ALREADY_EXISTS){
		CloseHandle(hMutex);
		MessageBox(NULL,"ERROR_ALREADY_EXISTS","",MB_OK);
		ExitProcess(0);
	}
	extern DataEngine* g_pEg;
	DataEngine* pEg=new DataEngine();
	pEg->InitDatabase();
	g_pEg=pEg;
 	// TODO: Place code here.
	Login* pLoginDlg = new Login();
	pLoginDlg->CreateUI();

	AppEnv::Run();
	return 0;
}
